package com.shhm.business.controller;

import com.shhm.business.dto.request.OrderSearchReq;
import com.shhm.business.service.OrderService;
import com.shhm.common.annotations.OperateLog;
import com.shhm.common.dto.request.RequestList;
import com.shhm.common.dto.response.AjaxResultPlus;
import com.shhm.common.dto.response.business.OrderVO;
import com.shhm.common.entity.common.OrderEntity;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.web.bind.annotation.*;

/**
 * @author JackZ
 * @version 1.0
 * @description: TODO
 * @date 2025/9/15 上午11:56
 */
@RestController
public class OrderController {
    @Resource
    private OrderService orderService;

    @GetMapping("/admin/order")
    public AjaxResultPlus pageList(
            @RequestParam(defaultValue = "1") Integer pageNum,
            @RequestParam(defaultValue = "10") Integer pageSize,
            HttpServletRequest request,
            @RequestParam(defaultValue = "1") Integer isPage
    ){
        return orderService.pageList(pageNum,pageSize,isPage,request);
    }

    @PostMapping("/admin/order/search")
    public AjaxResultPlus pageSearchList(
            @RequestParam(defaultValue = "1") Integer pageNum,
            @RequestParam(defaultValue = "10") Integer pageSize,
            @RequestBody OrderSearchReq entity
    ){
        return orderService.pageSearchList(pageNum,pageSize,entity);
    }

    @PostMapping("/admin/order")
    @OperateLog(module="订单管理",type = "POST",desc = "添加业务订单信息")
    public AjaxResultPlus add(@RequestBody OrderEntity entity){
        return orderService.add(entity);
    }

    @PutMapping("/admin/order")
    @OperateLog(module="订单管理",type = "PUT",desc = "修改业务订单信息")
    public AjaxResultPlus update(@RequestBody OrderEntity entity){
        return orderService.update(entity);
    }

    @DeleteMapping("/admin/order")
    @OperateLog(module="订单管理",type = "DELETE",desc = "删除业务订单")
    public AjaxResultPlus delete(@RequestBody RequestList ids){
        return orderService.delete(ids);
    }
}
